<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>作用域基础</title>
</head>
<body>
<div id="app">
    <cpn>
        <!--  scope 代表的是当前接收所有变量使用的名称，自身的类型是一个对象  -->
        <template v-slot:cpn="scope">
            <h2>{{ scope.info }}</h2>
            <h2>{{ scope.grate }}</h2>
        </template>
    </cpn>

    <hr>

    <cpn>
        <!--  语法糖，使用#  -->
        <template #cpn="scope">
            <h2>{{ scope.info }}</h2>
            <h2>{{ scope.grate }}</h2>
        </template>
    </cpn>
</div>


<template id="cpn">
    <h1>世界，您好！</h1>
    <!--    <slot name="cpn" info="Hi, Vue!"></slot>-->
    <!--    <slot name="cpn" v-bind:info="message"></slot>-->
    <slot name="cpn" v-bind:info="message" v-bind:grate="grate"></slot>
    <h1>Hello, World!</h1>
</template>
<script type="module">
    import {createApp, ref} from "../../../../js/vue.esm-browser.js";
    import {defineComponent} from "../../../../js/vue.esm-browser.js";

    let cpn = defineComponent(
        {
            template: "#cpn",
            setup() {
                let message = ref("Hi, Vue!")
                let grate = ref("Hi, SCCT!")
                return {
                    message,
                    grate,
                }
            }
        }
    );

    let app = createApp(
        {
            setup() {
                return {}
            },
            components: {
                cpn,
            }
        }
    )
    app.mount("#app")
</script>
</body>
</html>